home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / marginwidget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-06  |  6.2 KB  |  224 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #ifndef MARGINWIDGET_H
  8. #define MARGINWIDGET_H
  9.  
  10. #include "scribusapi.h"
  11. #include "scribusstructs.h"
  12.  
  13. #include <QComboBox>
  14. #include <QTabWidget>
  15. #include "linkbutton.h"
  16. class QCheckBox;
  17. class QPushButton;
  18. class QLabel;
  19. class QGridLayout;
  20. class QHBoxLayout;
  21. class ScrSpinBox;
  22.  
  23.  
  24. /*! \brief This is inherited QComboBox widget used in MarginWidget as "Preset List".
  25. It contains functionality for margins setting in various ways.
  26. \author Petr Vanek, <petr@yarpen.cz>
  27. */
  28. class SCRIBUS_API PresetLayout: public QComboBox
  29. {
  30.     Q_OBJECT
  31.  
  32. public:
  33.     /*! \brief QComboBox like constructor. Values/names are set here. Tooltip etc. too. */
  34.     PresetLayout(QWidget *parent = 0);
  35.     ~PresetLayout(){};
  36.  
  37.     /*! \brief Compute the margins here.
  38.     \param index selected item
  39.     \param pageWidth width of the page. Taken from NewDoc dialog.
  40.     \param pageHeight height of the page. Taken from NewDoc dialog.
  41.     \param leftMargin leadin margin value. The others margins are set in various ratios related to this one.
  42.     */
  43.     MarginStruct getMargins(int index, double pageWidth, double pageHeight, double leftMargin);
  44.  
  45.     /*! \brief Integerized indexes for tr() strings*/
  46.     enum presetID
  47.     {
  48.         none = 0,
  49.         gutenberg = 1,
  50.         magazine = 2,
  51.         fibonacci = 3,
  52.         goldencut = 4,
  53.         nineparts = 5
  54.     };
  55.  
  56.     /*! \brief returns updateMargins value */
  57.     bool needUpdate() const;
  58.  
  59. private:
  60.     /*! \brief Flag if is needed to recompute values and disable widgets */
  61.     bool updateMargins;
  62. };
  63.  
  64.  
  65. /*! \brief Widget for Margins setting.
  66. Used e.g. in "New Doc Dialog" or "Preferences".
  67. */
  68. class SCRIBUS_API MarginWidget : public QTabWidget
  69. {
  70.     Q_OBJECT
  71.  
  72. public:
  73.     /*! \brief It creates an user interface for base margin settings for the document.
  74.     \param parent Parent widget (used as standard in Qt)
  75.     \param title Title of the Group box
  76.     \param margs A reference to the margins in the preferences.
  77.     \param unitIndex and index of the unit combobox
  78.     \param showChangeAll show "apply to all pages" related items
  79.     */
  80.     MarginWidget( QWidget* parent, QString title, const MarginStruct* margs, int unitIndex, bool showChangeAll=false, bool showBleeds=true);
  81.     ~MarginWidget() {};
  82.     /*! \brief Setup the labels by facing pages option */
  83.     void setFacingPages(bool facing, int pagetype = 0);
  84.     /*! \brief Setup the spinboxes properties (min/max value etc.) by width and height */
  85.     void setPageWidthHeight(double width, double height);
  86.     /*! \brief Setup the spinboxes properties (min/max value etc.) by width */
  87.     void setPageWidth(double width);
  88.     /*! \brief Setup the spinboxes properties (min/max value etc.) by height */
  89.     void setPageHeight(double heigth);
  90.     /*! \brief Setup the widgets by new options */
  91.     void setNewUnit(int newUnitIndex);
  92.     /*! \brief Set the page size for margin getting from cups */
  93.     void setPageSize(const QString& pageSize);
  94.     
  95.     /*! \brief Margins
  96.     \retval MarginStruct data */
  97.     const MarginStruct& margins() const;
  98.     /*! \brief Top Margin
  99.     \retval double margin size */
  100.     double top() const;
  101.     /*! \brief Bottom Margin
  102.     \retval double margin size */
  103.     double bottom() const;
  104.     /*! \brief Left Margin
  105.     \retval double margin size */
  106.     double left() const;
  107.     /*! \brief Right Margin
  108.     \retval double margin size */
  109.     double right() const;
  110.  
  111.     /*! \brief set new margin values for the dialog
  112.     It calls overridden setTop(), setBottom() etc. slots itself
  113.     via signals emitted from spinboxes.
  114.     \param m MarginStruct 
  115.     */
  116.     void setNewMargins(MarginStruct& m);
  117.     
  118.     /*! \brief Setup the presetCombo without changing the margin values, only used by tabdocument */
  119.     void setMarginPreset(int p);
  120.     int getMarginPreset();
  121.     
  122.     /*! \brief Top Bleed
  123.     \retval double bleed size */
  124.     double topBleed() const;
  125.     /*! \brief Bottom Bleed
  126.     \retval double bleed size */
  127.     double bottomBleed() const;
  128.     /*! \brief Left Bleed
  129.     \retval double bleed size */
  130.     double leftBleed() const;
  131.     /*! \brief Right Bleed
  132.     \retval double bleed size */
  133.     double rightBleed() const;
  134.  
  135.     /*! \brief set new bleed values for the dialog
  136.     \param b MarginStruct
  137.     */
  138.     void setNewBleeds(MarginStruct& b);
  139.     
  140.     /*! \brief Return marginsForAllPages property
  141.     \retval bool true to apply for all pages */
  142.     bool getMarginsForAllPages() const;
  143.     bool getMarginsForAllMasterPages() const;
  144.  
  145. private:
  146.     /*! Tabs */
  147.     QWidget *marginPage;
  148.     QWidget* bleedPage;
  149.     /*! Spinboxes */
  150.     ScrSpinBox* topR;
  151.     ScrSpinBox* bottomR;
  152.     ScrSpinBox* rightR;
  153.     ScrSpinBox* leftR;
  154.     ScrSpinBox* BleedBottom;
  155.     ScrSpinBox* BleedLeft;
  156.     ScrSpinBox* BleedRight;
  157.     ScrSpinBox* BleedTop;
  158.     PresetLayout* presetCombo;
  159.     /*! Labels */
  160.     QLabel* lText;
  161.     QLabel* rText;
  162.     QLabel* tText;
  163.     QLabel* bText;
  164.     QLabel* presetLabel;
  165.     QLabel* marginsForPages;
  166.     QLabel* BleedTxt1;
  167.     QLabel* BleedTxt2;
  168.     QLabel* BleedTxt3;
  169.     QLabel* BleedTxt4;
  170.     QCheckBox* marginsForAllPages;
  171.     QCheckBox* marginsForAllMasterPages;
  172.     QPushButton* usePrinterMarginsButton;
  173.     LinkButton* linkBleeds;
  174.     LinkButton* linkMargins;
  175.     /*! \brief Margin values converted by unitRatio */
  176.     MarginStruct marginData;
  177.     /*
  178.     //! \brief Top margin value converted by unitRatio
  179.     double RandT;
  180.     //! \brief Bottom margin value converted by unitRatio
  181.     double RandB;
  182.     //! \brief Left margin value converted by unitRatio
  183.     double RandL;
  184.     //! \brief Right margin value converted by unitRatio
  185.     double RandR;
  186.     */
  187.     /*! \brief Internally used page width */
  188.     double pageWidth;
  189.     /*! \brief Internally used page height */
  190.     double pageHeight;
  191.  
  192. public slots:
  193.     /*! \brief Recompute the values after spinbox change */
  194.     void setTop();
  195.     void setBottom();
  196.     void setLeft();
  197.     void setRight();
  198.     /*! \brief Recompute margins in PresetLayout combobox and disable/enable widgets. */
  199.     void setPreset();
  200.     void slotLinkBleeds();
  201.     void slotLinkMargins();
  202.     void changeBleeds();
  203.     
  204. protected slots:    
  205.     virtual void setMarginsToPrinterMargins();
  206.  
  207. protected:
  208.     void updateMarginSpinValues();
  209.     QGridLayout* GroupLayout;
  210.     QHBoxLayout* marginsForPagesLayout;
  211.     QGridLayout* BleedGroupLayout;
  212.     QString m_pageSize;
  213.     int m_unitIndex;
  214.     double m_unitRatio;
  215.     //! \brief if the outer facing palette points to the facing pages item
  216.     bool facingPages;
  217.     bool useBleeds;
  218.     int pageType;
  219.     MarginStruct savedMargins;
  220.     int savedPresetItem;
  221. };
  222.  
  223. #endif
  224.